<script>
    async function async1 () {
        console.log('1');
        await async2();
        console.log('2');
    }
    async function async2 () {
        console.log('3');
    }
    console.log('4');
    setTimeout(function () {
        console.log('5');
    }, 0);
    async1();
    new Promise(function (resolve) {
        console.log('6');
        resolve();
    }).then(function () {
        console.log('7');
    });
    console.log('8');
</script>
<!-- 
<script>
    console.log(1);
    // --------------
    // await 函数()
    // 其他代码
    //  -------------
    // 执行这个函数，跳出这个aysnc，把其他代码，加到微任务
    async function fnOne() {
      console.log(2);
      await fnTwo(); 
      console.log(3);
    }
    async function fnTwo() {
      console.log(4);
    }
    fnOne();
    setTimeout(() => {  console.log(5); }, 2000);
    let p = new Promise((resolve, reject) => { // new Promise()里的函数体会马上执行所有代码
      console.log(6);
      resolve();
      console.log(7);
    })
    setTimeout(() => {
      console.log(8)
    }, 0)
    p.then(() => {
      console.log(9);
    })
    console.log(10);
</script>

<script>
    console.log(11);
    setTimeout(() => {
      console.log(12);
      let p = new Promise((resolve) => {
        resolve(13);
      })
      p.then(res => {
        console.log(res);
      })
      console.log(15);
    }, 0)
    console.log(14);
  </script> -->

